//
//  AppDelegate.h
//  Address-book📞
//
//  Created by Mars_ZXB on 16/8/6.
//  Copyright © 2016年 BAT3. All rights reserved.
//


#import "HandleImage.h"
#import "ModelOfContact.h"
#import "SandboxHandler.h"
@implementation HandleImage

+ (void)saveImageWith:(ModelOfContact *)model {
    NSString *imageName = [NSString stringWithFormat:@"%@head", model.name];
    NSString *pathFile = [SandboxHandler pathForDirectory:Documents WithFileName:imageName];
    NSData *data = UIImageJPEGRepresentation(model.image, 1);
    [data writeToFile:pathFile atomically:YES];
    
}

+ (void)loadImage:(ModelOfContact *)model {
    NSString *imageName = [NSString stringWithFormat:@"%@head", model.name];
    NSString *pathFile = [SandboxHandler pathForDirectory:Documents WithFileName:imageName];
    NSData *data = [NSData dataWithContentsOfFile:pathFile];
    model.image = [UIImage imageWithData:data];
}
@end
